<html>
<head><meta charset="utf-8"><title>Handling non evaluatable constants&#x27; equality · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants&#x27;.20equality.html">Handling non evaluatable constants&#x27; equality</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="238386348"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Handling%20non%20evaluatable%20constants%27%20equality/near/238386348" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jade <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants&#x27;.20equality.html#238386348">(May 11 2021 at 21:41)</a>:</h4>
<p>Hi! I'm working on some stuff ( <a href="https://github.com/rust-analyzer/rust-analyzer/pull/8799#issuecomment-839015078">https://github.com/rust-analyzer/rust-analyzer/pull/8799#issuecomment-839015078</a>) in rust analyzer, and we're adding partial constant evaluation support. As part of this, we have a variant of our ConcreteConst type we give to chalk that represents a computation that we don't know how to do, but probably is not erroneous.</p>
<p>Previously, when all computations were like this, we returned true always from const_eq in our Interner, but now that we have some simple computations that do actually have known concrete values, we sometimes have a real answer. The question I have is, what should our return value for const equality be, to achieve the most correct result the most of the time, in cases where one or both of the operands don't have known values due to our constant evaluation limitations?</p>



<a name="238439693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Handling%20non%20evaluatable%20constants%27%20equality/near/238439693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants&#x27;.20equality.html#238439693">(May 12 2021 at 08:32)</a>:</h4>
<p>eddyb <a href="https://github.com/rust-analyzer/rust-analyzer/pull/8799/files#r630152210">mentioned</a> that rustc sometimes defers const equality obligations for later (if I understood it right). How does Chalk deal with this? Is this not necessary in Chalk's model?</p>



<a name="238616336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Handling%20non%20evaluatable%20constants%27%20equality/near/238616336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants&#x27;.20equality.html#238616336">(May 13 2021 at 12:48)</a>:</h4>
<p>ping, not to let this topic get buried <span aria-label="grimacing" class="emoji emoji-1f62c" role="img" title="grimacing">:grimacing:</span> </p>
<p>rustc seems to implement Chalk's <code>ConcreteConst</code> directly as an evaluated constant. How does it deal with something like <code>N - 1</code>?</p>
<p>do constants not need 'lazy' evaluation/normalization?</p>



<a name="238616614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Handling%20non%20evaluatable%20constants%27%20equality/near/238616614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants&#x27;.20equality.html#238616614">(May 13 2021 at 12:51)</a>:</h4>
<p>I'm pretty sure <code>N - 1</code> would be represented as an <code>Unevaluated</code> not a <code>ConcreteConst</code></p>



<a name="238616732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Handling%20non%20evaluatable%20constants%27%20equality/near/238616732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants&#x27;.20equality.html#238616732">(May 13 2021 at 12:53)</a>:</h4>
<p><a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/enum.ConstKind.html">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/enum.ConstKind.html</a></p>



<a name="238616896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Handling%20non%20evaluatable%20constants%27%20equality/near/238616896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants&#x27;.20equality.html#238616896">(May 13 2021 at 12:55)</a>:</h4>
<p><a href="https://github.com/rust-lang/chalk/issues/596">chalk#596</a> would have added <code>Unevaluated</code>, but we have basically no design directions and it became inactive, so it was closed</p>



<a name="238616955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Handling%20non%20evaluatable%20constants%27%20equality/near/238616955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants&#x27;.20equality.html#238616955">(May 13 2021 at 12:55)</a>:</h4>
<p>That being said, this is probably something we should have a design meeting to specifically talk about how we want to handle const evaluation in Chalk</p>



<a name="238617028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Handling%20non%20evaluatable%20constants%27%20equality/near/238617028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants&#x27;.20equality.html#238617028">(May 13 2021 at 12:56)</a>:</h4>
<p>And try to get people like <span class="user-mention" data-user-id="216206">@lcnr</span> and the <span class="user-group-mention" data-user-group-id="3805">@project-const-generics</span> group involved for that</p>



<a name="238617059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Handling%20non%20evaluatable%20constants%27%20equality/near/238617059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Florian Diebold <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants&#x27;.20equality.html#238617059">(May 13 2021 at 12:56)</a>:</h4>
<p>aha, that makes things make a lot more sense</p>



<a name="238617068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Handling%20non%20evaluatable%20constants%27%20equality/near/238617068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Boxy [she/her] <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants&#x27;.20equality.html#238617068">(May 13 2021 at 12:56)</a>:</h4>
<p>I'd been wondering how chalk was gonna handle const generics stuff <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="238617123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Handling%20non%20evaluatable%20constants%27%20equality/near/238617123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants&#x27;.20equality.html#238617123">(May 13 2021 at 12:57)</a>:</h4>
<p>Yeah, short answer: we don't know</p>



<a name="238619190"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Handling%20non%20evaluatable%20constants%27%20equality/near/238619190" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants&#x27;.20equality.html#238619190">(May 13 2021 at 13:16)</a>:</h4>
<p>it would be good to press on :)</p>



<a name="238619193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Handling%20non%20evaluatable%20constants%27%20equality/near/238619193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants&#x27;.20equality.html#238619193">(May 13 2021 at 13:16)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="216206">@lcnr</span></p>



<a name="238636619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Handling%20non%20evaluatable%20constants%27%20equality/near/238636619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants&#x27;.20equality.html#238636619">(May 13 2021 at 15:24)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232957">Jack Huey</span> <a href="#narrow/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants'.20equality/near/238616614">said</a>:</p>
<blockquote>
<p>I'm pretty sure <code>N - 1</code> would be represented as an <code>Unevaluated</code> not a <code>ConcreteConst</code></p>
</blockquote>
<p>yes</p>



<a name="238636660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Handling%20non%20evaluatable%20constants%27%20equality/near/238636660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants&#x27;.20equality.html#238636660">(May 13 2021 at 15:24)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232957">Jack Huey</span> <a href="#narrow/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants'.20equality/near/238616955">said</a>:</p>
<blockquote>
<p>That being said, this is probably something we should have a design meeting to specifically talk about how we want to handle const evaluation in Chalk</p>
</blockquote>
<p>seems good</p>



<a name="238636802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Handling%20non%20evaluatable%20constants%27%20equality/near/238636802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants&#x27;.20equality.html#238636802">(May 13 2021 at 15:25)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants'.20equality/near/238619193">said</a>:</p>
<blockquote>
<p>cc <span class="user-mention silent" data-user-id="216206">lcnr</span></p>
</blockquote>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> is there already something specific i should comment on here?</p>



<a name="238638767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Handling%20non%20evaluatable%20constants%27%20equality/near/238638767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants&#x27;.20equality.html#238638767">(May 13 2021 at 15:40)</a>:</h4>
<p>Probably not :)</p>



<a name="238642403"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Handling%20non%20evaluatable%20constants%27%20equality/near/238642403" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants&#x27;.20equality.html#238642403">(May 13 2021 at 16:06)</a>:</h4>
<p>heh, no I guess not</p>



<a name="238642422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Handling%20non%20evaluatable%20constants%27%20equality/near/238642422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Handling.20non.20evaluatable.20constants&#x27;.20equality.html#238642422">(May 13 2021 at 16:06)</a>:</h4>
<p>I just wanted to be sure you'd seen the topic</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>